import 'package:ecy_app_flutter/ecycommon/EcyCommonWidgets.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import '../../EcyRouter.dart';
import '../../constant/color_constant.dart';

class EcyLoginPage extends EcyCommonBaseWidget {
  EcyLoginPage({required super.key});

  @override
  _EcyLoginPageState createState() {
    return _EcyLoginPageState();
  }
}

class _EcyLoginPageState extends EcyCommonBaseWidgetState {
  bool checked = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: ColorConstant.White,
        appBar: AppBar(
          backgroundColor: ColorConstant.White,
          title: Text(this.title),
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            const Image(
                image: AssetImage('assets/images/login_app_icon.png'),
                width: 80,
                height: 80),
            SizedBox(width: MediaQuery.of(context).size.width, height: 16),
            GestureDetector(
                onTap: () {
                  if (!checked) {
                    showToast("请先勾选协议", context: context);
                  } else {
                    EcyRouter.pushNoParams(context, EcyRouter.mobileLoginPage);
                  }
                },
                child: Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(26),
                    color: ColorConstant.CommonColor,
                  ),
                  margin: const EdgeInsets.only(
                      left: 22, right: 22, top: 117, bottom: 10.0),
                  width: MediaQuery.of(context).size.width - 44,
                  height: 52,
                  alignment: Alignment.center,
                  child: const Text('微信登录',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontFamily: "PingFang SC",
                          fontWeight: FontWeight.w700,
                          fontSize: 18,
                          color: ColorConstant.White)),
                )),
            GestureDetector(
                onTap: () {
                  if (!checked) {
                    showToast("请先勾选协议", context: context);
                  } else {
                    EcyRouter.pushNoParams(context, EcyRouter.mobileLoginPage);
                  }
                },
                child: Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(26),
                    color: ColorConstant.CommonColorLight,
                  ),
                  margin: const EdgeInsets.only(
                      left: 22, right: 22, top: 14, bottom: 10.0),
                  width: MediaQuery.of(context).size.width - 44,
                  height: 52,
                  alignment: Alignment.center,
                  child: const Text('手机号登录',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontFamily: "PingFang SC",
                          fontWeight: FontWeight.w700,
                          fontSize: 18,
                          color: ColorConstant.CommonColor)),
                )),
            GestureDetector(
                onTap: () {
                  if (!checked) {
                    showToast("请先勾选协议", context: context);
                  } else {
                    EcyRouter.pushNoParams(context, EcyRouter.mobileLoginPage);
                  }
                },
                child: Container(
                  margin: const EdgeInsets.only(
                      left: 22, right: 22, top: 14, bottom: 10.0),
                  width: MediaQuery.of(context).size.width - 44,
                  height: 32,
                  alignment: Alignment.center,
                  child: const Text('账号密码登录',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontFamily: "PingFang SC",
                          fontWeight: FontWeight.w700,
                          fontSize: 16,
                          color: ColorConstant.CommonColor)),
                )),
            Expanded(
              child: Container(
                color: Colors.transparent,
              ),
            ),
            Wrap(
              direction: Axis.horizontal,
              spacing: 0,
              children: [
                GestureDetector(
                  onTap: () => {
                    setState(() {
                      checked = !checked;
                    }),
                    print('checkedt' + checked.toString()),
                  },
                  child: Image(
                      image: AssetImage(checked
                          ? 'assets/images/login_checked.png'
                          : 'assets/images/login_unchecked.png'),
                      width: 34,
                      height: 34),
                ),
                Container(
                  width: MediaQuery.of(context).size.width - 40,
                  child: GestureDetector(
                      onTap: () => print('Tapped outside highlighted text'),
                      child: RichText(
                        text: TextSpan(
                          children: [
                            const TextSpan(
                              text: '新手机号将自动注册，已详细阅读同意',
                              style: TextStyle(
                                  color: Color.fromARGB(255, 140, 140, 140),
                                  fontSize: 16),
                            ),
                            TextSpan(
                                recognizer: TapGestureRecognizer()
                                  ..onTap = () {
                                    print('Tapped outside highlighted text22');
                                  },
                                text: '《使用条款和个人信息保护政策》',
                                style: TextStyle(
                                    color: ColorConstant.CommonColor,
                                    fontSize: 16)),
                          ],
                        ),
                      )),
                ),
              ],
            ),
            SizedBox(width: MediaQuery.of(context).size.width, height: 40),
          ],
        ));
  }
}
